﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public enum BuildingTypeEnum
{
    empty, wall, upstair, downstair, door
}

public class Building
{
    public static Dictionary<string, BuildingTypeEnum> dictionary;
    public static List<Building> _list;
    public static List<Building> list {
        get{
            if (Building._list == null){
                init();
            }
            return Building._list;
        }
    }
    public static Building wall { get; private set; }
    public static Building empty { get; private set; }

    public string pic { get; private set; }
    public BuildingTypeEnum type { get; private set; }

    public static void init()
    {
        dictionary = new Dictionary<string, BuildingTypeEnum>();
        dictionary.Add("mota_5", BuildingTypeEnum.empty);
        dictionary.Add("mota_6", BuildingTypeEnum.empty);
        dictionary.Add("mota_7", BuildingTypeEnum.wall);
        dictionary.Add("mota_8", BuildingTypeEnum.wall);
        dictionary.Add("mota_9", BuildingTypeEnum.wall);
        dictionary.Add("mota_0", BuildingTypeEnum.door);
        dictionary.Add("mota_10", BuildingTypeEnum.upstair);
        dictionary.Add("mota_11", BuildingTypeEnum.downstair);

        _list = new List<Building>();
        empty = new Building("mota_5", BuildingTypeEnum.empty);
        wall = new Building("mota_7", BuildingTypeEnum.wall);
        list.Add(new Building("mota_5", BuildingTypeEnum.empty));
        list.Add(new Building("mota_6", BuildingTypeEnum.empty));
        list.Add(new Building("mota_7", BuildingTypeEnum.wall));
        list.Add(new Building("mota_8", BuildingTypeEnum.wall));
        list.Add(new Building("mota_9", BuildingTypeEnum.wall));
        list.Add(new Building("mota_0", BuildingTypeEnum.door));
        list.Add(new Building("mota_10", BuildingTypeEnum.upstair));
        list.Add(new Building("mota_11", BuildingTypeEnum.downstair));
    }

    public static BuildingTypeEnum getTypeByPic(string picName)
    {
        if (Building.dictionary == null)
        {
            Building.init();
        }
        return Building.dictionary[picName];
    }

    public Building(string pic, BuildingTypeEnum type)
    {
        this.pic = pic;
        this.type = type;
    }

}

